import request from '@/request/index.js'

/**
 * @param {Object} code
 * 登录
 */
export function login(code){
	let url = '/api/user/login'
	let data = {code}
	return request.post(url,data)
}

/**
 * 调试登录
 * @param {Object} userId
 */
export function testLogin(code){
	let url = `/api/user/test/login`
	let data = {code}
	return request.post(url,data)
}

/**
 * 注册
 * @param {Object} topUserId
 * @param {Object} avatar
 * @param {Object} name
 * @param {Object} openId
 * @param {Object} unionId
 */
export function register(topUserId,avatar,name,openId,unionId,phone){
	let url = `/api/user/register`
	let data = {
		phone,topUserId,avatar,name,openId,unionId,Loading:true
	}
	return request.post(url,data)
}

export function getWxPhone(iv ,data){
	let url = '/api/user/wx/phone'
	let params = {iv,data}
	return request.get(url,{params})
}

/**
 * 获取用户信息
 */
export function getUserInfo(){
	let url = '/api/user/info'
	return request.get(url)
}


//获取账户信息
export function account(){
	let url = '/api/user/account'
	return request.get(url)
}

export function updateUser(user){
	let url = '/api/user/update'
	user.birth = user.birth+" 00:00:00"
	let data = {...user,Loading:true}
	return request.post(url,data)
}


/**
 * 获取用户信息
 */
export function recharge(amount){
	let url = '/api/user/recharge'
	let data = {amount:amount,Loading:true}
	return request.post(url,data)
}

//查找所有推广
export function findByTop(){
	let url = '/api/user/top'
	return request.get(url)
}

//所有交易记录
export function record(type,date){
	let url = '/api/user/record'
	let params = {type,date}
	return request.get(url,{params})
}

//交易参数
export function getRecordOptions(){
	let url = '/account/record/dmz/options'
	return request.get(url)
}
